
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/calculus/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:04 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Calculus &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="index.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Category Theory" href="../categories.html" />
    <link rel="prev" title="Predicates" href="../assumptions/predicates.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../categories.html" title="Category Theory"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../assumptions/predicates.html" title="Predicates"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Calculus</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.calculus">
<span id="calculus"></span><h1>Calculus<a class="headerlink" href="#module-sympy.calculus" title="Permalink to this headline">¶</a></h1>
<p>Calculus-related methods.</p>
<span class="target" id="module-sympy.calculus.euler"></span><p>This module implements a method to find
Euler-Lagrange Equations for given Lagrangian.</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.euler.euler_equations">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.euler.</span></span><span class="sig-name descname"><span class="pre">euler_equations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">L</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">funcs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vars</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/euler.py#L10-L103"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.euler.euler_equations" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the Euler-Lagrange equations <a class="reference internal" href="#r26" id="id1"><span>[R26]</span></a> for a given Lagrangian.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>L</strong> : Expr</p>
<blockquote>
<div><p>The Lagrangian that should be a function of the functions listed
in the second argument and their derivatives.</p>
<p>For example, in the case of two functions <span class="math notranslate nohighlight">\(f(x,y)\)</span>, <span class="math notranslate nohighlight">\(g(x,y)\)</span> and
two independent variables <span class="math notranslate nohighlight">\(x\)</span>, <span class="math notranslate nohighlight">\(y\)</span> the Lagrangian would have the form:</p>
<blockquote>
<div><div class="math notranslate nohighlight">
\[L\left(f(x,y),g(x,y),\frac{\partial f(x,y)}{\partial x},
\frac{\partial f(x,y)}{\partial y},
\frac{\partial g(x,y)}{\partial x},
\frac{\partial g(x,y)}{\partial y},x,y\right)\]</div>
</div></blockquote>
<p>In many cases it is not necessary to provide anything, except the
Lagrangian, it will be auto-detected (and an error raised if this
couldn’t be done).</p>
</div></blockquote>
<p><strong>funcs</strong> : Function or an iterable of Functions</p>
<blockquote>
<div><p>The functions that the Lagrangian depends on. The Euler equations
are differential equations for each of these functions.</p>
</div></blockquote>
<p><strong>vars</strong> : Symbol or an iterable of Symbols</p>
<blockquote>
<div><p>The Symbols that are the independent variables of the functions.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>eqns</strong> : list of Eq</p>
<blockquote>
<div><p>The list of differential equations, one for each function.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">Function</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.euler</span> <span class="kn">import</span> <span class="n">euler_equations</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">t</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">L</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span><span class="p">(</span><span class="n">t</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">t</span><span class="p">))</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="mi">2</span> <span class="o">-</span> <span class="n">x</span><span class="p">(</span><span class="n">t</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">euler_equations</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">x</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="n">t</span><span class="p">)</span>
<span class="go">[Eq(-x(t) - Derivative(x(t), (t, 2)), 0)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;u&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">L</span> <span class="o">=</span> <span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">t</span><span class="p">))</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="mi">2</span> <span class="o">-</span> <span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">))</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">euler_equations</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">u</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">x</span><span class="p">),</span> <span class="p">[</span><span class="n">t</span><span class="p">,</span> <span class="n">x</span><span class="p">])</span>
<span class="go">[Eq(-Derivative(u(t, x), (t, 2)) + Derivative(u(t, x), (x, 2)), 0)]</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r26"><span class="brackets">R26</span><span class="fn-backref">(<a href="#id1">1</a>,<a href="#id2">2</a>)</span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Euler–Lagrange_equation">https://en.wikipedia.org/wiki/Euler%E2%80%93Lagrange_equation</a></p>
</dd>
</dl>
</dd></dl>

<span class="target" id="module-sympy.calculus.singularities"></span><section id="singularities">
<h2>Singularities<a class="headerlink" href="#singularities" title="Permalink to this headline">¶</a></h2>
<p>This module implements algorithms for finding singularities for a function
and identifying types of functions.</p>
<p>The differential calculus methods in this module include methods to identify
the following function types in the given <code class="docutils literal notranslate"><span class="pre">Interval</span></code>:
- Increasing
- Strictly Increasing
- Decreasing
- Strictly Decreasing
- Monotonic</p>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.is_decreasing">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">is_decreasing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L245-L285"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.is_decreasing" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the function is decreasing in the given interval.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function which is being checked.</p>
</div></blockquote>
<p><strong>interval</strong> : Set, optional</p>
<blockquote>
<div><p>The range of values in which we are testing (defaults to set of
all real numbers).</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol, optional</p>
<blockquote>
<div><p>The symbol present in expression which gets varied over the given range.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>True if <code class="docutils literal notranslate"><span class="pre">expression</span></code> is decreasing (either strictly decreasing or
constant) in the given <code class="docutils literal notranslate"><span class="pre">interval</span></code>, False otherwise.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">is_decreasing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_decreasing</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="mf">1.5</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_decreasing</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Lopen</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_decreasing</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Ropen</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_decreasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_decreasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.is_increasing">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">is_increasing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L159-L199"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.is_increasing" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the function is increasing in the given interval.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function which is being checked.</p>
</div></blockquote>
<p><strong>interval</strong> : Set, optional</p>
<blockquote>
<div><p>The range of values in which we are testing (defaults to set of
all real numbers).</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol, optional</p>
<blockquote>
<div><p>The symbol present in expression which gets varied over the given range.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>True if <code class="docutils literal notranslate"><span class="pre">expression</span></code> is increasing (either strictly increasing or
constant) in the given <code class="docutils literal notranslate"><span class="pre">interval</span></code>, False otherwise.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">is_increasing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_increasing</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_increasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_increasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_increasing</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">72</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">30</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_increasing</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.is_monotonic">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">is_monotonic</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L329-L386"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.is_monotonic" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the function is monotonic in the given interval.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function which is being checked.</p>
</div></blockquote>
<p><strong>interval</strong> : Set, optional</p>
<blockquote>
<div><p>The range of values in which we are testing (defaults to set of
all real numbers).</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol, optional</p>
<blockquote>
<div><p>The symbol present in expression which gets varied over the given range.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>True if <code class="docutils literal notranslate"><span class="pre">expression</span></code> is monotonic in the given <code class="docutils literal notranslate"><span class="pre">interval</span></code>,
False otherwise.</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>Monotonicity check has not been implemented for the queried function.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">is_monotonic</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_monotonic</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="mf">1.5</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_monotonic</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Lopen</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_monotonic</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_monotonic</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_monotonic</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.is_strictly_decreasing">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">is_strictly_decreasing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L288-L326"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.is_strictly_decreasing" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the function is strictly decreasing in the given interval.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function which is being checked.</p>
</div></blockquote>
<p><strong>interval</strong> : Set, optional</p>
<blockquote>
<div><p>The range of values in which we are testing (defaults to set of
all real numbers).</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol, optional</p>
<blockquote>
<div><p>The symbol present in expression which gets varied over the given range.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>True if <code class="docutils literal notranslate"><span class="pre">expression</span></code> is strictly decreasing in the given <code class="docutils literal notranslate"><span class="pre">interval</span></code>,
False otherwise.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">is_strictly_decreasing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_decreasing</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Lopen</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_decreasing</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Ropen</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_decreasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_decreasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.is_strictly_increasing">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">is_strictly_increasing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L202-L242"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.is_strictly_increasing" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the function is strictly increasing in the given interval.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function which is being checked.</p>
</div></blockquote>
<p><strong>interval</strong> : Set, optional</p>
<blockquote>
<div><p>The range of values in which we are testing (defaults to set of
all real numbers).</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol, optional</p>
<blockquote>
<div><p>The symbol present in expression which gets varied over the given range.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>True if <code class="docutils literal notranslate"><span class="pre">expression</span></code> is strictly increasing in the given <code class="docutils literal notranslate"><span class="pre">interval</span></code>,
False otherwise.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">is_strictly_increasing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_increasing</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">72</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">30</span><span class="p">,</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Ropen</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_increasing</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">72</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">30</span><span class="p">,</span> <span class="n">Interval</span><span class="o">.</span><span class="n">Lopen</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_increasing</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span> <span class="o">-</span> <span class="mi">6</span><span class="o">*</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">72</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">30</span><span class="p">,</span> <span class="n">Interval</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_increasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_strictly_increasing</span><span class="p">(</span><span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.monotonicity_helper">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">monotonicity_helper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">predicate</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">interval</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L112-L156"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.monotonicity_helper" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function for functions checking function monotonicity.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function which is being checked</p>
</div></blockquote>
<p><strong>predicate</strong> : function</p>
<blockquote>
<div><p>The property being tested for. The function takes in an integer
and returns a boolean. The integer input is the derivative and
the boolean result should be true if the property is being held,
and false otherwise.</p>
</div></blockquote>
<p><strong>interval</strong> : Set, optional</p>
<blockquote>
<div><p>The range of values in which we are testing, defaults to all reals.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol, optional</p>
<blockquote>
<div><p>The symbol present in expression which gets varied over the given range.</p>
</div></blockquote>
<p><strong>It returns a boolean indicating whether the interval in which</strong></p>
<p><strong>the function’s derivative satisfies given predicate is a superset</strong></p>
<p><strong>of the given interval.</strong></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>True if <code class="docutils literal notranslate"><span class="pre">predicate</span></code> is true for all the derivatives when <code class="docutils literal notranslate"><span class="pre">symbol</span></code>
is varied in <code class="docutils literal notranslate"><span class="pre">range</span></code>, False otherwise.</p>
</div></blockquote>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.singularities.singularities">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.singularities.</span></span><span class="sig-name descname"><span class="pre">singularities</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/singularities.py#L24-L104"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.singularities.singularities" title="Permalink to this definition">¶</a></dt>
<dd><p>Find singularities of a given function.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expression</strong> : Expr</p>
<blockquote>
<div><p>The target function in which singularities need to be found.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The symbol over the values of which the singularity in
expression in being searched for.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Set</p>
<blockquote>
<div><p>A set of values for <code class="docutils literal notranslate"><span class="pre">symbol</span></code> for which <code class="docutils literal notranslate"><span class="pre">expression</span></code> has a
singularity. An <code class="docutils literal notranslate"><span class="pre">EmptySet</span></code> is returned if <code class="docutils literal notranslate"><span class="pre">expression</span></code> has no
singularities for any given value of <code class="docutils literal notranslate"><span class="pre">Symbol</span></code>.</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>Methods for determining the singularities of this function have
not been developed.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>This function does not find non-isolated singularities
nor does it find branch points of the expression.</p>
<dl class="simple">
<dt>Currently supported functions are:</dt><dd><ul class="simple">
<li><p>univariate continuous (real or complex) functions</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.singularities</span> <span class="kn">import</span> <span class="n">singularities</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">log</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">real</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">singularities</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">EmptySet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">singularities</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">{-1}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">singularities</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">y</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">y</span><span class="p">)</span>
<span class="go">{-I, I}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">singularities</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">y</span><span class="o">**</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">y</span><span class="p">)</span>
<span class="go">{-1, 1/2 - sqrt(3)*I/2, 1/2 + sqrt(3)*I/2}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">singularities</span><span class="p">(</span><span class="n">log</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">{0}</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r27"><span class="brackets"><a class="fn-backref" href="#id3">R27</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Mathematical_singularity">https://en.wikipedia.org/wiki/Mathematical_singularity</a></p>
</dd>
</dl>
</dd></dl>

</section>
<span class="target" id="module-sympy.calculus.finite_diff"><span id="finite-diff"></span></span><section id="finite-difference-weights">
<h2>Finite difference weights<a class="headerlink" href="#finite-difference-weights" title="Permalink to this headline">¶</a></h2>
<p>This module implements an algorithm for efficient generation of finite
difference weights for ordinary differentials of functions for
derivatives from 0 (interpolation) up to arbitrary order.</p>
<p>The core algorithm is provided in the finite difference weight generating
function (<code class="docutils literal notranslate"><span class="pre">finite_diff_weights</span></code>), and two convenience functions are provided
for:</p>
<ul class="simple">
<li><dl class="simple">
<dt>estimating a derivative (or interpolate) directly from a series of points</dt><dd><p>is also provided (<code class="docutils literal notranslate"><span class="pre">apply_finite_diff</span></code>).</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt>differentiating by using finite difference approximations</dt><dd><p>(<code class="docutils literal notranslate"><span class="pre">differentiate_finite</span></code>).</p>
</dd>
</dl>
</li>
</ul>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.finite_diff.apply_finite_diff">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.finite_diff.</span></span><span class="sig-name descname"><span class="pre">apply_finite_diff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x0</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/finite_diff.py#L201-L286"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.finite_diff.apply_finite_diff" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the finite difference approximation of
the derivative of requested order at <code class="docutils literal notranslate"><span class="pre">x0</span></code> from points
provided in <code class="docutils literal notranslate"><span class="pre">x_list</span></code> and <code class="docutils literal notranslate"><span class="pre">y_list</span></code>.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order: int</strong></p>
<blockquote>
<div><p>order of derivative to approximate. 0 corresponds to interpolation.</p>
</div></blockquote>
<p><strong>x_list: sequence</strong></p>
<blockquote>
<div><p>Sequence of (unique) values for the independent variable.</p>
</div></blockquote>
<p><strong>y_list: sequence</strong></p>
<blockquote>
<div><p>The function value at corresponding values for the independent
variable in x_list.</p>
</div></blockquote>
<p><strong>x0: Number or Symbol</strong></p>
<blockquote>
<div><p>At what value of the independent variable the derivative should be
evaluated. Defaults to 0.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>sympy.core.add.Add or sympy.core.numbers.Number</p>
<blockquote>
<div><p>The finite difference expression approximating the requested
derivative order at <code class="docutils literal notranslate"><span class="pre">x0</span></code>.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus</span> <span class="kn">import</span> <span class="n">apply_finite_diff</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cube</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">arg</span><span class="p">:</span> <span class="p">(</span><span class="mf">1.0</span><span class="o">*</span><span class="n">arg</span><span class="p">)</span><span class="o">**</span><span class="mi">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">xlist</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="o">-</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">apply_finite_diff</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">xlist</span><span class="p">,</span> <span class="nb">map</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="n">xlist</span><span class="p">),</span> <span class="mi">2</span><span class="p">)</span> <span class="o">-</span> <span class="mi">12</span> 
<span class="go">-3.55271367880050e-15</span>
</pre></div>
</div>
<p>we see that the example above only contain rounding errors.
apply_finite_diff can also be used on more abstract objects:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">IndexedBase</span><span class="p">,</span> <span class="n">Idx</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus</span> <span class="kn">import</span> <span class="n">apply_finite_diff</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">IndexedBase</span><span class="p">,</span> <span class="s1">&#39;xy&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">i</span> <span class="o">=</span> <span class="n">Idx</span><span class="p">(</span><span class="s1">&#39;i&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x_list</span><span class="p">,</span> <span class="n">y_list</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="p">[(</span><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="n">j</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="n">j</span><span class="p">])</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">apply_finite_diff</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">x_list</span><span class="p">,</span> <span class="n">y_list</span><span class="p">,</span> <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
<span class="go">((x[i + 1] - x[i])/(-x[i - 1] + x[i]) - 1)*y[i]/(x[i + 1] - x[i]) -</span>
<span class="go">(x[i + 1] - x[i])*y[i - 1]/((x[i + 1] - x[i - 1])*(-x[i - 1] + x[i])) +</span>
<span class="go">(-x[i - 1] + x[i])*y[i + 1]/((x[i + 1] - x[i - 1])*(x[i + 1] - x[i]))</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>Order = 0 corresponds to interpolation.
Only supply so many points you think makes sense
to around x0 when extracting the derivative (the function
need to be well behaved within that region). Also beware
of Runge’s phenomenon.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.calculus.finite_diff.finite_diff_weights" title="sympy.calculus.finite_diff.finite_diff_weights"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.calculus.finite_diff.finite_diff_weights</span></code></a></p>
</div>
<p class="rubric">References</p>
<p>Fortran 90 implementation with Python interface for numerics: <a class="reference external" href="https://github.com/bjodah/finitediff">finitediff</a></p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.finite_diff.as_finite_diff">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.finite_diff.</span></span><span class="sig-name descname"><span class="pre">as_finite_diff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">derivative</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">points</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x0</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wrt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/finite_diff.py#L289-L412"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.finite_diff.as_finite_diff" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated function. Use Diff.as_finite_difference instead.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.finite_diff.differentiate_finite">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.finite_diff.</span></span><span class="sig-name descname"><span class="pre">differentiate_finite</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">symbols</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">points</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x0</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wrt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">evaluate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/finite_diff.py#L424-L486"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.finite_diff.differentiate_finite" title="Permalink to this definition">¶</a></dt>
<dd><p>Differentiate expr and replace Derivatives with finite differences.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>expr</strong> : expression</p>
<p><strong>*symbols</strong> : differentiate with respect to symbols</p>
<p><strong>points: sequence, coefficient or undefined function, optional</strong></p>
<blockquote>
<div><p>see <code class="docutils literal notranslate"><span class="pre">Derivative.as_finite_difference</span></code></p>
</div></blockquote>
<p><strong>x0: number or Symbol, optional</strong></p>
<blockquote>
<div><p>see <code class="docutils literal notranslate"><span class="pre">Derivative.as_finite_difference</span></code></p>
</div></blockquote>
<p><strong>wrt: Symbol, optional</strong></p>
<blockquote>
<div><p>see <code class="docutils literal notranslate"><span class="pre">Derivative.as_finite_difference</span></code></p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">sin</span><span class="p">,</span> <span class="n">Function</span><span class="p">,</span> <span class="n">differentiate_finite</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">h</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">,</span> <span class="n">g</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">),</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;g&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">differentiate_finite</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">g</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">points</span><span class="o">=</span><span class="p">[</span><span class="n">x</span><span class="o">-</span><span class="n">h</span><span class="p">,</span> <span class="n">x</span><span class="o">+</span><span class="n">h</span><span class="p">])</span>
<span class="go">-f(-h + x)*g(-h + x)/(2*h) + f(h + x)*g(h + x)/(2*h)</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">differentiate_finite</span></code> works on any expression, including the expressions
with embedded derivatives:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">differentiate_finite</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">-2*f(x) + f(x - 1) + f(x + 1) - 2*sin(x) + sin(x - 1) + sin(x + 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">differentiate_finite</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="go">f(x - 1/2, y - 1/2) - f(x - 1/2, y + 1/2) - f(x + 1/2, y - 1/2) + f(x + 1/2, y + 1/2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">differentiate_finite</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">g</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">(-g(x) + g(x + 1))*f(x + 1/2) - (g(x) - g(x - 1))*f(x - 1/2)</span>
</pre></div>
</div>
<p>To make finite difference with non-constant discretization step use
undefined functions:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dx</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;dx&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">differentiate_finite</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">g</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">points</span><span class="o">=</span><span class="n">dx</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="go">-(-g(x - dx(x)/2 - dx(x - dx(x)/2)/2)/dx(x - dx(x)/2) +</span>
<span class="go">g(x - dx(x)/2 + dx(x - dx(x)/2)/2)/dx(x - dx(x)/2))*f(x - dx(x)/2)/dx(x) +</span>
<span class="go">(-g(x + dx(x)/2 - dx(x + dx(x)/2)/2)/dx(x + dx(x)/2) +</span>
<span class="go">g(x + dx(x)/2 + dx(x + dx(x)/2)/2)/dx(x + dx(x)/2))*f(x + dx(x)/2)/dx(x)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.finite_diff.finite_diff_weights">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.finite_diff.</span></span><span class="sig-name descname"><span class="pre">finite_diff_weights</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">order</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x0</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/finite_diff.py#L28-L198"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.finite_diff.finite_diff_weights" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the finite difference weights for an arbitrarily spaced
one-dimensional grid (<code class="docutils literal notranslate"><span class="pre">x_list</span></code>) for derivatives at <code class="docutils literal notranslate"><span class="pre">x0</span></code> of order
0, 1, …, up to <code class="docutils literal notranslate"><span class="pre">order</span></code> using a recursive formula. Order of accuracy
is at least <code class="docutils literal notranslate"><span class="pre">len(x_list)</span> <span class="pre">-</span> <span class="pre">order</span></code>, if <code class="docutils literal notranslate"><span class="pre">x_list</span></code> is defined correctly.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>order: int</strong></p>
<blockquote>
<div><p>Up to what derivative order weights should be calculated.
0 corresponds to interpolation.</p>
</div></blockquote>
<p><strong>x_list: sequence</strong></p>
<blockquote>
<div><p>Sequence of (unique) values for the independent variable.
It is useful (but not necessary) to order <code class="docutils literal notranslate"><span class="pre">x_list</span></code> from
nearest to furthest from <code class="docutils literal notranslate"><span class="pre">x0</span></code>; see examples below.</p>
</div></blockquote>
<p><strong>x0: Number or Symbol</strong></p>
<blockquote>
<div><p>Root or value of the independent variable for which the finite
difference weights should be generated. Default is <code class="docutils literal notranslate"><span class="pre">S.One</span></code>.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>list</p>
<blockquote>
<div><p>A list of sublists, each corresponding to coefficients for
increasing derivative order, and each containing lists of
coefficients for increasing subsets of x_list.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus</span> <span class="kn">import</span> <span class="n">finite_diff_weights</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span> <span class="o">=</span> <span class="n">finite_diff_weights</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">-</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span> <span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span>
<span class="go">[[[1, 0, 0, 0],</span>
<span class="go">  [1/2, 1/2, 0, 0],</span>
<span class="go">  [3/8, 3/4, -1/8, 0],</span>
<span class="go">  [5/16, 15/16, -5/16, 1/16]],</span>
<span class="go"> [[0, 0, 0, 0],</span>
<span class="go">  [-1, 1, 0, 0],</span>
<span class="go">  [-1, 1, 0, 0],</span>
<span class="go">  [-23/24, 7/8, 1/8, -1/24]]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>  <span class="c1"># FD weights for 0th derivative, using full x_list</span>
<span class="go">[5/16, 15/16, -5/16, 1/16]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>  <span class="c1"># FD weights for 1st derivative</span>
<span class="go">[-23/24, 7/8, 1/8, -1/24]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span>  <span class="c1"># FD weights for 1st derivative, using x_list[:-1]</span>
<span class="go">[-1, 1, 0, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># FD weight for 1st deriv. for x_list[0]</span>
<span class="go">-23/24</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>  <span class="c1"># FD weight for 1st deriv. for x_list[1], etc.</span>
<span class="go">7/8</span>
</pre></div>
</div>
<p>Each sublist contains the most accurate formula at the end.
Note, that in the above example <code class="docutils literal notranslate"><span class="pre">res[1][1]</span></code> is the same as <code class="docutils literal notranslate"><span class="pre">res[1][2]</span></code>.
Since res[1][2] has an order of accuracy of
<code class="docutils literal notranslate"><span class="pre">len(x_list[:3])</span> <span class="pre">-</span> <span class="pre">order</span> <span class="pre">=</span> <span class="pre">3</span> <span class="pre">-</span> <span class="pre">1</span> <span class="pre">=</span> <span class="pre">2</span></code>, the same is true for <code class="docutils literal notranslate"><span class="pre">res[1][1]</span></code>!</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus</span> <span class="kn">import</span> <span class="n">finite_diff_weights</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span> <span class="o">=</span> <span class="n">finite_diff_weights</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="n">S</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="o">-</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="o">-</span><span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="mi">0</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span>
<span class="go">[[0, 0, 0, 0, 0],</span>
<span class="go"> [-1, 1, 0, 0, 0],</span>
<span class="go"> [0, 1/2, -1/2, 0, 0],</span>
<span class="go"> [-1/2, 1, -1/3, -1/6, 0],</span>
<span class="go"> [0, 2/3, -2/3, -1/12, 1/12]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># no approximation possible, using x_list[0] only</span>
<span class="go">[0, 0, 0, 0, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>  <span class="c1"># classic forward step approximation</span>
<span class="go">[-1, 1, 0, 0, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>  <span class="c1"># classic centered approximation</span>
<span class="go">[0, 1/2, -1/2, 0, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">res</span><span class="p">[</span><span class="mi">3</span><span class="p">:]</span>  <span class="c1"># higher order approximations</span>
<span class="go">[[-1/2, 1, -1/3, -1/6, 0], [0, 2/3, -2/3, -1/12, 1/12]]</span>
</pre></div>
</div>
<p>Let us compare this to a differently defined <code class="docutils literal notranslate"><span class="pre">x_list</span></code>. Pay attention to
<code class="docutils literal notranslate"><span class="pre">foo[i][k]</span></code> corresponding to the gridpoint defined by <code class="docutils literal notranslate"><span class="pre">x_list[k]</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus</span> <span class="kn">import</span> <span class="n">finite_diff_weights</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">foo</span> <span class="o">=</span> <span class="n">finite_diff_weights</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="o">-</span><span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="o">-</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">S</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="mi">0</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">foo</span>
<span class="go">[[0, 0, 0, 0, 0],</span>
<span class="go"> [-1, 1, 0, 0, 0],</span>
<span class="go"> [1/2, -2, 3/2, 0, 0],</span>
<span class="go"> [1/6, -1, 1/2, 1/3, 0],</span>
<span class="go"> [1/12, -2/3, 0, 2/3, -1/12]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">foo</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>  <span class="c1"># not the same and of lower accuracy as res[1]!</span>
<span class="go">[-1, 1, 0, 0, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">foo</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>  <span class="c1"># classic double backward step approximation</span>
<span class="go">[1/2, -2, 3/2, 0, 0]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">foo</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span>  <span class="c1"># the same as res[4]</span>
<span class="go">[1/12, -2/3, 0, 2/3, -1/12]</span>
</pre></div>
</div>
<p>Note that, unless you plan on using approximations based on subsets of
<code class="docutils literal notranslate"><span class="pre">x_list</span></code>, the order of gridpoints does not matter.</p>
<p>The capability to generate weights at arbitrary points can be
used e.g. to minimize Runge’s phenomenon by using Chebyshev nodes:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">cos</span><span class="p">,</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">simplify</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus</span> <span class="kn">import</span> <span class="n">finite_diff_weights</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">N</span><span class="p">,</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="o">=</span> <span class="mi">4</span><span class="p">,</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;h x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x_list</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">+</span><span class="n">h</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">i</span><span class="o">*</span><span class="n">pi</span><span class="o">/</span><span class="p">(</span><span class="n">N</span><span class="p">))</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">N</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">)]</span> <span class="c1"># chebyshev nodes</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">x_list</span><span class="p">)</span>
<span class="go">[-h + x, -sqrt(2)*h/2 + x, x, sqrt(2)*h/2 + x, h + x]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mycoeffs</span> <span class="o">=</span> <span class="n">finite_diff_weights</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">x_list</span><span class="p">,</span> <span class="mi">0</span><span class="p">)[</span><span class="mi">1</span><span class="p">][</span><span class="mi">4</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">simplify</span><span class="p">(</span><span class="n">c</span><span class="p">)</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span>  <span class="n">mycoeffs</span><span class="p">]</span> 
<span class="go">[(h**3/2 + h**2*x - 3*h*x**2 - 4*x**3)/h**4,</span>
<span class="go">(-sqrt(2)*h**3 - 4*h**2*x + 3*sqrt(2)*h*x**2 + 8*x**3)/h**4,</span>
<span class="go">(6*h**2*x - 8*x**3)/h**4,</span>
<span class="go">(sqrt(2)*h**3 - 4*h**2*x - 3*sqrt(2)*h*x**2 + 8*x**3)/h**4,</span>
<span class="go">(-h**3/2 + h**2*x + 3*h*x**2 - 4*x**3)/h**4]</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>If weights for a finite difference approximation of 3rd order
derivative is wanted, weights for 0th, 1st and 2nd order are
calculated “for free”, so are formulae using subsets of <code class="docutils literal notranslate"><span class="pre">x_list</span></code>.
This is something one can take advantage of to save computational cost.
Be aware that one should define <code class="docutils literal notranslate"><span class="pre">x_list</span></code> from nearest to furthest from
<code class="docutils literal notranslate"><span class="pre">x0</span></code>. If not, subsets of <code class="docutils literal notranslate"><span class="pre">x_list</span></code> will yield poorer approximations,
which might not grand an order of accuracy of <code class="docutils literal notranslate"><span class="pre">len(x_list)</span> <span class="pre">-</span> <span class="pre">order</span></code>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.calculus.finite_diff.apply_finite_diff" title="sympy.calculus.finite_diff.apply_finite_diff"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.calculus.finite_diff.apply_finite_diff</span></code></a></p>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r28"><span class="brackets"><a class="fn-backref" href="#id4">R28</a></span></dt>
<dd><p>Generation of Finite Difference Formulas on Arbitrarily Spaced
Grids, Bengt Fornberg; Mathematics of computation; 51; 184;
(1988); 699-706; doi:10.1090/S0025-5718-1988-0935077-0</p>
</dd>
</dl>
</dd></dl>

</section>
<span class="target" id="module-sympy.calculus.util"></span><dl class="py attribute">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumBounds">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">AccumBounds</span></span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L852-L1536"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.AccumBounds" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <a class="reference internal" href="#sympy.calculus.util.AccumulationBounds" title="sympy.calculus.util.AccumulationBounds"><code class="xref py py-class docutils literal notranslate"><span class="pre">sympy.calculus.util.AccumulationBounds</span></code></a></p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumulationBounds">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">AccumulationBounds</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L852-L1536"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.AccumulationBounds" title="Permalink to this definition">¶</a></dt>
<dd><p># Note AccumulationBounds has an alias: AccumBounds</p>
<p>AccumulationBounds represent an interval <span class="math notranslate nohighlight">\([a, b]\)</span>, which is always closed
at the ends. Here <span class="math notranslate nohighlight">\(a\)</span> and <span class="math notranslate nohighlight">\(b\)</span> can be any value from extended real numbers.</p>
<p>The intended meaning of AccummulationBounds is to give an approximate
location of the accumulation points of a real function at a limit point.</p>
<p>Let <span class="math notranslate nohighlight">\(a\)</span> and <span class="math notranslate nohighlight">\(b\)</span> be reals such that a &lt;= b.</p>
<p><span class="math notranslate nohighlight">\(\left\langle a, b\right\rangle = \{x \in \mathbb{R} \mid a \le x \le b\}\)</span></p>
<p><span class="math notranslate nohighlight">\(\left\langle -\infty, b\right\rangle = \{x \in \mathbb{R} \mid x \le b\} \cup \{-\infty, \infty\}\)</span></p>
<p><span class="math notranslate nohighlight">\(\left\langle a, \infty \right\rangle = \{x \in \mathbb{R} \mid a \le x\} \cup \{-\infty, \infty\}\)</span></p>
<p><span class="math notranslate nohighlight">\(\left\langle -\infty, \infty \right\rangle = \mathbb{R} \cup \{-\infty, \infty\}\)</span></p>
<p><span class="math notranslate nohighlight">\(oo\)</span> and <span class="math notranslate nohighlight">\(-oo\)</span> are added to the second and third definition respectively,
since if either <span class="math notranslate nohighlight">\(-oo\)</span> or <span class="math notranslate nohighlight">\(oo\)</span> is an argument, then the other one should
be included (though not as an end point). This is forced, since we have,
for example, <span class="math notranslate nohighlight">\(1/AccumBounds(0, 1) = AccumBounds(1, oo)\)</span>, and the limit at
<span class="math notranslate nohighlight">\(0\)</span> is not one-sided. As x tends to <span class="math notranslate nohighlight">\(0-\)</span>, then <span class="math notranslate nohighlight">\(1/x -&gt; -oo\)</span>, so <span class="math notranslate nohighlight">\(-oo\)</span>
should be interpreted as belonging to <span class="math notranslate nohighlight">\(AccumBounds(1, oo)\)</span> though it need
not appear explicitly.</p>
<p>In many cases it suffices to know that the limit set is bounded.
However, in some other cases more exact information could be useful.
For example, all accumulation values of cos(x) + 1 are non-negative.
(AccumBounds(-1, 1) + 1 = AccumBounds(0, 2))</p>
<p>A AccumulationBounds object is defined to be real AccumulationBounds,
if its end points are finite reals.</p>
<p>Let <span class="math notranslate nohighlight">\(X\)</span>, <span class="math notranslate nohighlight">\(Y\)</span> be real AccumulationBounds, then their sum, difference,
product are defined to be the following sets:</p>
<p><span class="math notranslate nohighlight">\(X + Y = \{ x+y \mid x \in X \cap y \in Y\}\)</span></p>
<p><span class="math notranslate nohighlight">\(X - Y = \{ x-y \mid x \in X \cap y \in Y\}\)</span></p>
<p><span class="math notranslate nohighlight">\(X * Y = \{ x*y \mid x \in X \cap y \in Y\}\)</span></p>
<p>When an AccumBounds is raised to a negative power, if 0 is contained
between the bounds then an infinite range is returned, otherwise if an
endpoint is 0 then a semi-infinite range with consistent sign will be returned.</p>
<p>AccumBounds in expressions behave a lot like Intervals but the
semantics are not necessarily the same. Division (or exponentiation
to a negative integer power) could be handled with <em>intervals</em> by
returning a union of the results obtained after splitting the
bounds between negatives and positives, but that is not done with
AccumBounds. In addition, bounds are assumed to be independent of
each other; if the same bound is used in more than one place in an
expression, the result may not be the supremum or infimum of the
expression (see below). Finally, when a boundary is <code class="docutils literal notranslate"><span class="pre">1</span></code>,
exponentiation to the power of <code class="docutils literal notranslate"><span class="pre">oo</span></code> yields <code class="docutils literal notranslate"><span class="pre">oo</span></code>, neither
<code class="docutils literal notranslate"><span class="pre">1</span></code> nor <code class="docutils literal notranslate"><span class="pre">nan</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">AccumBounds</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">exp</span><span class="p">,</span> <span class="n">log</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">E</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">AccumBounds(1, 3)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-</span> <span class="n">AccumBounds</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">AccumBounds(-2, 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">AccumBounds(-3, 3)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">*</span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
<span class="go">AccumBounds(3, 10)</span>
</pre></div>
</div>
<p>The exponentiation of AccumulationBounds is defined
as follows:</p>
<p>If 0 does not belong to <span class="math notranslate nohighlight">\(X\)</span> or <span class="math notranslate nohighlight">\(n &gt; 0\)</span> then</p>
<p><span class="math notranslate nohighlight">\(X^n = \{ x^n \mid x \in X\}\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span><span class="o">**</span><span class="p">(</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="go">AccumBounds(1, 2)</span>
</pre></div>
</div>
<p>otherwise, an infinite or semi-infinite result is obtained:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span><span class="o">/</span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">AccumBounds(-oo, oo)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span><span class="o">/</span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">AccumBounds(1/2, oo)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">1</span><span class="o">/</span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="n">oo</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="go">AccumBounds(-oo, 0)</span>
</pre></div>
</div>
<p>A boundary of 1 will always generate all nonnegatives:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span><span class="o">**</span><span class="n">oo</span>
<span class="go">AccumBounds(0, oo)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="n">oo</span>
<span class="go">AccumBounds(0, oo)</span>
</pre></div>
</div>
<p>If the exponent is itself an AccumulationBounds or is not an
integer then unevaluated results will be returned unless the base
values are positive:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">**</span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">AccumBounds(1/3, 9)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">**</span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="go">AccumBounds(-2, 3)**AccumBounds(-1, 2)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="p">(</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span>
<span class="go">sqrt(AccumBounds(-2, -1))</span>
</pre></div>
</div>
<p>Note: <span class="math notranslate nohighlight">\(&lt;a, b&gt;^2\)</span> is not same as <span class="math notranslate nohighlight">\(&lt;a, b&gt;*&lt;a, b&gt;\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span>
<span class="go">AccumBounds(0, 1)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">4</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="o">&lt;</span> <span class="o">-</span><span class="mi">1</span>
<span class="go">False</span>
</pre></div>
</div>
<p>Some elementary functions can also take AccumulationBounds as input.
A function <span class="math notranslate nohighlight">\(f\)</span> evaluated for some real AccumulationBounds <span class="math notranslate nohighlight">\(&lt;a, b&gt;\)</span>
is defined as <span class="math notranslate nohighlight">\(f(\left\langle a, b\right\rangle) = \{ f(x) \mid a \le x \le b \}\)</span></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">sin</span><span class="p">(</span><span class="n">AccumBounds</span><span class="p">(</span><span class="n">pi</span><span class="o">/</span><span class="mi">6</span><span class="p">,</span> <span class="n">pi</span><span class="o">/</span><span class="mi">3</span><span class="p">))</span>
<span class="go">AccumBounds(1/2, sqrt(3)/2)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">exp</span><span class="p">(</span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">AccumBounds(1, E)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">log</span><span class="p">(</span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">E</span><span class="p">))</span>
<span class="go">AccumBounds(0, 1)</span>
</pre></div>
</div>
<p>Some symbol in an expression can be substituted for a AccumulationBounds
object. But it doesn’t necessarily evaluate the AccumulationBounds for
that expression.</p>
<p>The same expression can be evaluated to different values depending upon
the form it is used for substitution since each instance of an
AccumulationBounds is considered independent. For example:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">subs</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">AccumBounds(-1, 4)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="p">((</span><span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">subs</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">AccumBounds</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="go">AccumBounds(0, 4)</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>Do not use <code class="docutils literal notranslate"><span class="pre">AccumulationBounds</span></code> for floating point interval arithmetic
calculations, use <code class="docutils literal notranslate"><span class="pre">mpmath.iv</span></code> instead.</p>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r29"><span class="brackets"><a class="fn-backref" href="#id5">R29</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Interval_arithmetic">https://en.wikipedia.org/wiki/Interval_arithmetic</a></p>
</dd>
<dt class="label" id="r30"><span class="brackets"><a class="fn-backref" href="#id6">R30</a></span></dt>
<dd><p><a class="reference external" href="http://fab.cba.mit.edu/classes/S62.12/docs/Hickey_interval.pdf">http://fab.cba.mit.edu/classes/S62.12/docs/Hickey_interval.pdf</a></p>
</dd>
</dl>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumulationBounds.delta">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">delta</span></span><a class="headerlink" href="#sympy.calculus.util.AccumulationBounds.delta" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the difference of maximum possible value attained by
AccumulationBounds object and minimum possible value attained
by AccumulationBounds object.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">AccumBounds</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">delta</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumulationBounds.intersection">
<span class="sig-name descname"><span class="pre">intersection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">other</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L1466-L1522"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.AccumulationBounds.intersection" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the intersection of ‘self’ and ‘other’.
Here other can be an instance of FiniteSet or AccumulationBounds.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>other: AccumulationBounds</strong></p>
<blockquote>
<div><p>Another AccumulationBounds object with which the intersection
has to be computed.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>AccumulationBounds</p>
<blockquote>
<div><p>Intersection of ‘self’ and ‘other’.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">AccumBounds</span><span class="p">,</span> <span class="n">FiniteSet</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
<span class="go">AccumBounds(2, 3)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">))</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">{1, 2}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumulationBounds.max">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">max</span></span><a class="headerlink" href="#sympy.calculus.util.AccumulationBounds.max" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the maximum possible value attained by AccumulationBounds
object.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">AccumBounds</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">max</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumulationBounds.mid">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">mid</span></span><a class="headerlink" href="#sympy.calculus.util.AccumulationBounds.mid" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the mean of maximum possible value attained by
AccumulationBounds object and minimum possible value
attained by AccumulationBounds object.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">AccumBounds</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">mid</span>
<span class="go">2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.calculus.util.AccumulationBounds.min">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">min</span></span><a class="headerlink" href="#sympy.calculus.util.AccumulationBounds.min" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the minimum possible value attained by AccumulationBounds
object.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">AccumBounds</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">AccumBounds</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">min</span>
<span class="go">1</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.continuous_domain">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">continuous_domain</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L19-L86"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.continuous_domain" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the intervals in the given domain for which the function
is continuous.
This method is limited by the ability to determine the various
singularities and discontinuities of the given function.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The variable for which the intervals are to be determined.</p>
</div></blockquote>
<p><strong>domain</strong> : Interval</p>
<blockquote>
<div><p>The domain over which the continuity of the symbol has to be checked.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Interval</p>
<blockquote>
<div><p>Union of all intervals where the function is continuous.</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>If the method to determine continuity of such a function
has not yet been developed.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">tan</span><span class="p">,</span> <span class="n">log</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">sqrt</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.util</span> <span class="kn">import</span> <span class="n">continuous_domain</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">continuous_domain</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Union(Interval.open(-oo, 0), Interval.open(0, oo))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">continuous_domain</span><span class="p">(</span><span class="n">tan</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">pi</span><span class="p">))</span>
<span class="go">Union(Interval.Ropen(0, pi/2), Interval.Lopen(pi/2, pi))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">continuous_domain</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">2</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="go">Interval(2, 5)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">continuous_domain</span><span class="p">(</span><span class="n">log</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Interval.open(1/2, oo)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.function_range">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">function_range</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L89-L222"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.function_range" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the range of a function in a given domain.
This method is limited by the ability to determine the singularities and
determine limits.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The variable for which the range of function is to be determined.</p>
</div></blockquote>
<p><strong>domain</strong> : Interval</p>
<blockquote>
<div><p>The domain under which the range of the function has to be found.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Interval</p>
<blockquote>
<div><p>Union of all ranges for all intervals under domain where function is
continuous.</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>If any of the intervals, in the given domain, for which function
is continuous are not finite or real,
OR if the critical points of the function on the domain can’t be found.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">exp</span><span class="p">,</span> <span class="n">log</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">tan</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.util</span> <span class="kn">import</span> <span class="n">function_range</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">function_range</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="go">Interval(-1, 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">function_range</span><span class="p">(</span><span class="n">tan</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">))</span>
<span class="go">Interval(-oo, oo)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">function_range</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Union(Interval.open(-oo, 0), Interval.open(0, oo))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">function_range</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Interval.open(0, oo)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">function_range</span><span class="p">(</span><span class="n">log</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">Interval(-oo, oo)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">function_range</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span> <span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">5</span><span class="p">,</span> <span class="mi">9</span><span class="p">))</span>
<span class="go">Interval(0, 3)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.is_convex">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">is_convex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">syms</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L627-L696"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.is_convex" title="Permalink to this definition">¶</a></dt>
<dd><p>Determines the  convexity of the function passed in the argument.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>syms</strong> : Tuple of symbols</p>
<blockquote>
<div><p>The variables with respect to which the convexity is to be determined.</p>
</div></blockquote>
<p><strong>domain</strong> : Interval, optional</p>
<blockquote>
<div><p>The domain over which the convexity of the function has to be checked.
If unspecified, S.Reals will be the default domain.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Boolean</p>
<blockquote>
<div><p>The method returns <span class="math notranslate nohighlight">\(True\)</span> if the function is convex otherwise it
returns <span class="math notranslate nohighlight">\(False\)</span>.</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>The check for the convexity of multivariate functions is not implemented yet.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>To determine concavity of a function pass <span class="math notranslate nohighlight">\(-f\)</span> as the concerned function.
To determine logarithmic convexity of a function pass log(f) as
concerned function.
To determine logartihmic concavity of a function pass -log(f) as
concerned function.</p>
<p>Currently, convexity check of multivariate functions is not handled.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">exp</span><span class="p">,</span> <span class="n">oo</span><span class="p">,</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.util</span> <span class="kn">import</span> <span class="n">is_convex</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_convex</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_convex</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">3</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span> <span class="o">=</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">oo</span><span class="p">))</span>
<span class="go">False</span>
</pre></div>
</div>
<p class="rubric">References</p>
<dl class="citation">
<dt class="label" id="r31"><span class="brackets"><a class="fn-backref" href="#id7">R31</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Convex_function">https://en.wikipedia.org/wiki/Convex_function</a></p>
</dd>
<dt class="label" id="r32"><span class="brackets"><a class="fn-backref" href="#id8">R32</a></span></dt>
<dd><p><a class="reference external" href="http://www.ifp.illinois.edu/~angelia/L3_convfunc.pdf">http://www.ifp.illinois.edu/~angelia/L3_convfunc.pdf</a></p>
</dd>
<dt class="label" id="r33"><span class="brackets"><a class="fn-backref" href="#id9">R33</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Logarithmically_convex_function">https://en.wikipedia.org/wiki/Logarithmically_convex_function</a></p>
</dd>
<dt class="label" id="r34"><span class="brackets"><a class="fn-backref" href="#id10">R34</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Logarithmically_concave_function">https://en.wikipedia.org/wiki/Logarithmically_concave_function</a></p>
</dd>
<dt class="label" id="r35"><span class="brackets"><a class="fn-backref" href="#id11">R35</a></span></dt>
<dd><p><a class="reference external" href="https://en.wikipedia.org/wiki/Concave_function">https://en.wikipedia.org/wiki/Concave_function</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.lcim">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">lcim</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">numbers</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L578-L625"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.lcim" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the least common integral multiple of a list of numbers.</p>
<p>The numbers can be rational or irrational or a mixture of both.
<span class="math notranslate nohighlight">\(None\)</span> is returned for incommensurable numbers.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>numbers</strong> : list</p>
<blockquote>
<div><p>Numbers (rational and/or irrational) for which lcim is to be found.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>number</p>
<blockquote>
<div><p>lcim if it exists, otherwise <span class="math notranslate nohighlight">\(None\)</span> for incommensurable numbers.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span><span class="p">,</span> <span class="n">pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.util</span> <span class="kn">import</span> <span class="n">lcim</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">lcim</span><span class="p">([</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">/</span><span class="mi">4</span><span class="p">,</span> <span class="n">S</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="o">/</span><span class="mi">6</span><span class="p">])</span>
<span class="go">15/2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">lcim</span><span class="p">([</span><span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="p">,</span> <span class="mi">3</span><span class="o">*</span><span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="o">/</span><span class="mi">2</span><span class="p">])</span>
<span class="go">6*pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">lcim</span><span class="p">([</span><span class="n">S</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="p">])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.maximum">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">maximum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L752-L799"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.maximum" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the maximum value of a function in the given domain.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The variable for maximum value needs to be determined.</p>
</div></blockquote>
<p><strong>domain</strong> : Interval</p>
<blockquote>
<div><p>The domain over which the maximum have to be checked.
If unspecified, then Global maximum is returned.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>number</p>
<blockquote>
<div><p>Maximum value of the function in given domain.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">maximum</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="o">-</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">maximum</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">6</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">maximum</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="o">-</span><span class="n">pi</span><span class="p">,</span> <span class="n">pi</span><span class="o">/</span><span class="mi">4</span><span class="p">))</span>
<span class="go">sqrt(2)/2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">maximum</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">1/2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.minimum">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">minimum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L802-L849"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.minimum" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the minimum value of a function in the given domain.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The variable for minimum value needs to be determined.</p>
</div></blockquote>
<p><strong>domain</strong> : Interval</p>
<blockquote>
<div><p>The domain over which the minimum have to be checked.
If unspecified, then Global minimum is returned.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>number</p>
<blockquote>
<div><p>Minimum value of the function in the given domain.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">minimum</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">5</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">minimum</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">4</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">minimum</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">sin(3)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">minimum</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">-1/2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.not_empty_in">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">not_empty_in</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">finset_intersection</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">syms</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L225-L333"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.not_empty_in" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the domain of the functions in <span class="math notranslate nohighlight">\(finite_set\)</span> in which the
<span class="math notranslate nohighlight">\(finite_set\)</span> is not-empty</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>finset_intersection</strong> : The unevaluated intersection of FiniteSet containing</p>
<blockquote>
<div><p>real-valued functions with Union of Sets</p>
</div></blockquote>
<p><strong>syms</strong> : Tuple of symbols</p>
<blockquote>
<div><p>Symbol for which domain is to be found</p>
</div></blockquote>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>The algorithms to find the non-emptiness of the given FiniteSet are
not yet implemented.</p>
</div></blockquote>
<p><strong>ValueError</strong></p>
<blockquote>
<div><p>The input is not valid.</p>
</div></blockquote>
<p><strong>RuntimeError</strong></p>
<blockquote>
<div><p>It is a bug, please report it to the github issue tracker
(<a class="reference external" href="https://github.com/sympy/sympy/issues">https://github.com/sympy/sympy/issues</a>).</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">FiniteSet</span><span class="p">,</span> <span class="n">Interval</span><span class="p">,</span> <span class="n">not_empty_in</span><span class="p">,</span> <span class="n">oo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">not_empty_in</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="n">x</span><span class="o">/</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Interval(0, 2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">not_empty_in</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Union(Interval(1, 2), Interval(-sqrt(2), -1))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">not_empty_in</span><span class="p">(</span><span class="n">FiniteSet</span><span class="p">(</span><span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">2</span><span class="p">))</span><span class="o">.</span><span class="n">intersect</span><span class="p">(</span><span class="n">Interval</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">oo</span><span class="p">)),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">Union(Interval.Lopen(-2, -1), Interval(2, oo))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.periodicity">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">periodicity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">check</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L336-L534"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.periodicity" title="Permalink to this definition">¶</a></dt>
<dd><p>Tests the given function for periodicity in the given symbol.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr.</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The variable for which the period is to be determined.</p>
</div></blockquote>
<p><strong>check</strong> : Boolean, optional</p>
<blockquote>
<div><p>The flag to verify whether the value being returned is a period or not.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>period</p>
<blockquote>
<div><p>The period of the function is returned.
<span class="math notranslate nohighlight">\(None\)</span> is returned when the function is aperiodic or has a complex period.
The value of <span class="math notranslate nohighlight">\(0\)</span> is returned as the period of a constant function.</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>The value of the period computed cannot be verified.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Currently, we do not support functions with a complex period.
The period of functions having complex periodic values such
as <span class="math notranslate nohighlight">\(exp\)</span>, <span class="math notranslate nohighlight">\(sinh\)</span> is evaluated to <span class="math notranslate nohighlight">\(None\)</span>.</p>
<p>The value returned might not be the “fundamental” period of the given
function i.e. it may not be the smallest periodic value of the function.</p>
<p>The verification of the period through the <span class="math notranslate nohighlight">\(check\)</span> flag is not reliable
due to internal simplification of the given expression. Hence, it is set
to <span class="math notranslate nohighlight">\(False\)</span> by default.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">tan</span><span class="p">,</span> <span class="n">exp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.calculus.util</span> <span class="kn">import</span> <span class="n">periodicity</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">sin</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">periodicity</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="go">2*pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">periodicity</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">periodicity</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">tan</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">pi/2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">periodicity</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="mi">4</span><span class="o">*</span><span class="n">x</span><span class="p">)</span><span class="o">**</span><span class="n">cos</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
<span class="go">pi</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">periodicity</span><span class="p">(</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="sympy.calculus.util.stationary_points">
<span class="sig-prename descclassname"><span class="pre">sympy.calculus.util.</span></span><span class="sig-name descname"><span class="pre">stationary_points</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Reals</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/calculus/util.py#L699-L749"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.calculus.util.stationary_points" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the stationary points of a function (where derivative of the
function is 0) in the given domain.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>f</strong> : Expr</p>
<blockquote>
<div><p>The concerned function.</p>
</div></blockquote>
<p><strong>symbol</strong> : Symbol</p>
<blockquote>
<div><p>The variable for which the stationary points are to be determined.</p>
</div></blockquote>
<p><strong>domain</strong> : Interval</p>
<blockquote>
<div><p>The domain over which the stationary points have to be checked.
If unspecified, S.Reals will be the default domain.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Set</p>
<blockquote>
<div><p>A set of stationary points for the function. If there are no
stationary point, an EmptySet is returned.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Symbol</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">pprint</span><span class="p">,</span> <span class="n">stationary_points</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.sets</span> <span class="kn">import</span> <span class="n">Interval</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">stationary_points</span><span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">S</span><span class="o">.</span><span class="n">Reals</span><span class="p">)</span>
<span class="go">EmptySet</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">stationary_points</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">use_unicode</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">          pi                              3*pi</span>
<span class="go">{2*n*pi + -- | n in Integers} U {2*n*pi + ---- | n in Integers}</span>
<span class="go">          2                                2</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">stationary_points</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">),</span><span class="n">x</span><span class="p">,</span> <span class="n">Interval</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">4</span><span class="o">*</span><span class="n">pi</span><span class="p">))</span>
<span class="go">{pi/2, 3*pi/2, 5*pi/2, 7*pi/2}</span>
</pre></div>
</div>
</dd></dl>

</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Calculus</a><ul>
<li><a class="reference internal" href="#singularities">Singularities</a></li>
<li><a class="reference internal" href="#finite-difference-weights">Finite difference weights</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="../assumptions/predicates.html"
                        title="previous chapter">Predicates</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../categories.html"
                        title="next chapter">Category Theory</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/calculus/index.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../categories.html" title="Category Theory"
             >next</a> |</li>
        <li class="right" >
          <a href="../assumptions/predicates.html" title="Predicates"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Calculus</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/calculus/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:04 GMT -->
</html>